package com.twotigers.tenthpower.qa.controller;

import java.util.Arrays;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.*;
import com.twotigers.tenthpower.qa.entity.PlEntity;
import com.twotigers.tenthpower.qa.service.PlService;
import io.renren.common.utils.PageUtils;
import io.renren.common.utils.R;



/**
 * 
 *
 * @author Erhu
 * @email 1935417243@qq.com
 * @date 2021-03-04 15:26:20
 */
@RestController
@RequestMapping("qa/pl")
public class PlController {
    @Autowired
    private PlService plService;

    /**
     * 列表
     */
    @GetMapping
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = plService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @GetMapping("/info/{problemid}")
    public R info(@PathVariable("problemid") String problemid){
		PlEntity pl = plService.getById(problemid);

        return R.ok().put("pl", pl);
    }

    /**
     * 保存
     */
    @PostMapping ("/save")
    public R save(@RequestBody PlEntity pl){
		plService.save(pl);

        return R.ok();
    }

    /**
     * 修改
     */
    @PutMapping("/update")
    public R update(@RequestBody PlEntity pl){
		plService.updateById(pl);

        return R.ok();
    }

    /**
     * 删除
     */
    @DeleteMapping("/delete")
    public R delete(@RequestBody String[] problemids){
		plService.removeByIds(Arrays.asList(problemids));

        return R.ok();
    }

}
